// Copyright 2019 The rhyme_lph Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// M [author] rhyme_lph
// s [email]  rhymelph@gmail.com
// I [github] https://github.com/rhymelph

import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/l10n.dart';
import 'package:finance_app/src/provider/setting/subscription/sub_invoice_provider.dart';
import 'package:finance_app/src/router_gen/router_meta.dart';
import 'package:finance_app/src/widgets/button/normal_popup_button.dart';
import 'package:finance_app/src/widgets/common/pdf_watch_view.dart';
import 'package:finance_app/src/widgets/common_app_bar.dart';
import 'package:flutter/material.dart';

@RouterMeta(paramName: "subInvoicePage")
class SubInvoicePage extends StatefulWidget {
  final int id;

  const SubInvoicePage({Key key, this.id}) : super(key: key);

  @override
  _SubInvoicePageState createState() => _SubInvoicePageState();
}

class _SubInvoicePageState extends State<SubInvoicePage>
    with PagePresenter<SubInvoicePage, SubInvoiceProvider> {
  @override
  void initState() {
    provider.id = widget.id;
    super.initState();
  }

  @override
  PreferredSizeWidget get appBar =>
      getDefaultAppBar(title: S.current.subscription_invoice, actions: [
        NormalMorePopupButton(
          onSelect: provider.onSelectMenu,
          menuList: provider.menuList,
        )
      ]);

  @override
  Widget get buildWidget => ColoredBox(
        color: Colors.white,
        child: PdfWatchView(
          key: provider.pdfKey,
          type: 'subscription',
          id: widget.id,
        ),
      );
}
